<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <search ref="search"  :config="searchConfig" @search="search" @getHeight="getHeight"/>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" @click="handleAdd">新增</a-button>
      <a-button type="primary" v-print="'#tableMiddles'">打印</a-button>
<!--      <a-button type="primary" @click="stateChange('003')">禁用</a-button>-->
<!--      <a-button type="primary" @click='batchDel'>删除</a-button>-->
      <!--      <a-button type="primary" >导入</a-button>-->
<!--      <a-button type='primary' icon='download' @click="downExportXls('tpm_act_categories_service')">导出</a-button>-->
    </div>
    <!-- table区域-begin -->
    <div  id="tableMiddles">
      <a-table
        ref="table"
        size="middle"
        class='Table'
        bordered
        rowKey="id"
        :scroll="{x:1500,y:pageHeight-seachHeight-220}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :customRow="onClickRow"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
       <span slot="remarks" slot-scope="text">
          <j-ellipsis :value="text" :length="15" />
        </span>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
        </span>
      </a-table>
    </div>

    <commit-modal ref="modalForm" @ok="modalFormOk"></commit-modal>
  </a-card>
</template>

<script>
import { PageListMixin } from '@/mixins/PageListMixin'
import { getAction, postAction } from '@api/manage'
import commitModal from './modules/commitModal'
import JEllipsis from "@/components/cn-form/JEllipsis";


export default {
  name: 'activitiesClass',
  mixins:[PageListMixin],
  components: {
    commitModal,
    JEllipsis
  },
  data () {

    return {
      description: '活动细类',
      searchConfig:[
        {
          // label:'订单编号',
          type:'input',
          name:'categoriesDetailCode',
          placeholder:'请输入调度单号',
        },{
          // label:'订单状态',
          type:'a-select',
          name:'status',
          option:[{
            name:'启用',
            value:'009'
          },{
            name:'停用',
            value:'003'
          }],
          placeholder:'请选择状态',
        },
        {
          type:'input',
          name:'categoriesDetailName',
          placeholder:'经销商名称',
        },{
          type:'input',
          name:'erpSubjectCode',
          placeholder:'物流公司',
        },{
          type:'a-select',
          name:'erpSubjectName1',
          option:[{
            name:'是',
            value:'1'
          },{
            name:'否',
            value:'0'
          }],
          placeholder:'是否传sap',
        },{
          type:'input',
          name:'erpSubjectName',
          placeholder:'创建人',
        }],
      // 表头
      columns: [
        // { type: 'checkbox', width: 50, fixed: null ,dataIndex: 'a',},
        {
          title: '调度单号',
          align: "left",
          dataIndex: 'mergeNo',
          width: 200,
          customRender: (value, row, index) => {
            let vm = this
            let child = vm.$createElement('a', {
              domProps: {
                innerHTML: value
              },
              on: {
                click: function() {
                  vm.onDblclicks(row)
                }
              }
            })
            const obj = {
              children: child,
              attrs: {}
            }
            return obj
          }
        },
        {
          title: '调度单状态',
          align: "left",
          dataIndex: 'mergeStatus',
          // width: 70,
          customRender: (value, row, index) => {
            let str='未调度'
            switch (value) {
              case 0:
                str='未调度'
                break;
              case 1:
                str='已调度'
                break;
              case 2:
                str='待提交'
                break;
            }
            const obj = {
              children: str,
              attrs: {}
            }
            return obj
          }
        },
        {
          title: '是否结算',
          align: "left",
          // width: 110,
          dataIndex: 'isSettlement',
          customRender: (value, row, index) => {
            let str='否'
            switch (value) {
              case 0:
                str='否'
                break;
              case 1:
                str='是'
                break;
            }
            const obj = {
              children: str,
              attrs: {}
            }
            return obj
          }
        },
        {
          title: '整车简装',
          align: "left",
          // width: 100,
          dataIndex: 'isFull',
          customRender: (value, row, index) => {
            let str='否'
            switch (value) {
              case 0:
                str='否'
                break;
              case 1:
                str='是'
                break;
            }
            const obj = {
              children: str,
              attrs: {}
            }
            return obj
          }
        },
        {
          title: '物流公司',
          align: "left",
          // width: 100,
          dataIndex: 'logistics',
        },
        {
          title: '车型（m）',
          align: "left",
          // width: 100,
          dataIndex: 'model',
        },
        {
          title: '司机姓名',
          align: "left",
          // width: 100,
          dataIndex: 'driverName',
        },
        {
          title: '司机电话',
          align: "left",
          // width: 100,
          dataIndex: 'driverTel',
        },
        {
          title: '车牌号',
          align: "left",
          // width: 90,
          dataIndex: 'carNumber'
        },
        {
          title: '订单总量',
          align: "left",
          // width: 90,
          dataIndex: 'orderNum'
        },
        {
          title: '标准件合计',
          align: "left",
          // width: 90,
          dataIndex: 'orderStandNum'
        },
        // {
        //   title: '重量合计',
        //   align: "left",
        //   // width: 90,
        //   dataIndex: 'isPrint'
        // },
        {
          title: '创建人',
          align: "left",
          width: 80,
          dataIndex: 'createName',

        },
        {
          title: '操作',
          dataIndex: 'action',
          fixed: 'right',
          align: 'center',
          width: 150,
          scopedSlots: {
            filterDropdown: 'filterDropdown',
            // filterIcon: 'filterIcon',
            customRender: 'action'
          }
        }
      ],

      url: {
        // 列表接口
        list: window._CONFIG['domianDmsURL']+ "/merge/findPageList",
        // 详情接口
        // detail: window._CONFIG['domianDmsURL']+ "/act/categories/findOne",
        // 导出接口
        // exportXlsUrl: window._CONFIG['domianTpmURL']+"budget/tpmBudgetFee/exportXls",
        // 删除接口
        deleteBatch:window._CONFIG['domianDmsURL']+ "/act/categories/delete",
        // 启停用接口
        status:window._CONFIG['domianDmsURL']+ "/act/categories/invokeOrBlockUp",
      },
    }
  },
  created() {
    this.queryParam.doc='订货单'

  },
  computed: {
    // importExcelUrl: function(){
    //   return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    // }
  },
  methods: {

    onDblclicks:async function (record){
      if (this.url.detail) {
        const res = await getAction(this.url.detail, {id: record.id})
        if (res && res.result) {
          record = res.result
        }else{
          this.$message.error(res.message)
        }
      }
      this.$refs.modalForm.edit(record);
      this.$refs.modalForm.title = "查看";
      this.$refs.modalForm.disableSubmit = true;
    },
  }
}
</script>

<style lang="less" scoped>
@import '~@assets/less/common.less';
/deep/ .ant-pagination{
  float:right;
}
</style>